import java.util.Scanner;

public class KeyWordTest3 {
    public static void main(String[] args) {
        //请输入一个合格的日期
        //年份是正整数、月份[1,12]，日期：[1,31或30或28或29]
        Scanner input = new Scanner(System.in);

        int year;
        while(true) {
            System.out.print("请输入年份（必须正数）：");
            year = input.nextInt();

            if (year <= 0) {
                System.out.println("请重新输入！");
            }else{
                break;
            }
        }

        int month;
        while(true){
            System.out.print("请输入月份[1,12]：");
            month = input.nextInt();
            if (month <1 || month>12) {
                System.out.println("请重新输入！");
            }else{
                break;
            }
        }

        int totalDays = 0;
        if(month==2){
            totalDays = year%4==0 && year%100!=0 || year%400==0 ? 29 : 28;
        }else if(month==4 || month==6 || month==9 || month==11){
            totalDays = 30;
        }else{
            totalDays = 31;
        }

        int day;
        while(true){
            System.out.print("请输入日期[1,"+totalDays+"]：");
            day = input.nextInt();
            if (day <1 || day>totalDays) {
                System.out.println("请重新输入！");
            }else{
                break;
            }
        }

        System.out.println(year + "年" + month + "月" + day +"日");


        input.close();
    }
}
